Skip to content

feat(clients): add PR auto-settle toggle - #5141

Open
caezium wants to merge 2 commits into
pingdotgg:mainfrom
caezium:feat/auto-settle-merged-pr-toggle
Open

feat(clients): add PR auto-settle toggle#5141
caezium wants to merge 2 commits into
pingdotgg:mainfrom
caezium:feat/auto-settle-merged-pr-toggle

Conversation

@caezium

@caezium caezium commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • Add an independent setting for settling Sidebar v2 threads when their pull request is merged or closed, enabled by default for backward compatibility.
  • Gate the shared settlement calculation on that setting while preserving manual settlement, explicit un-settlement, pending-work guards, and inactivity-based settlement.
  • Expose the control on web/desktop and mobile, and document how disabling both automatic triggers enables fully manual settlement.

Closes #4982.

Why

Sidebar v2 previously classified merged and closed pull-request threads as settled unconditionally. Disabling “Auto-settle inactive threads” therefore could not keep those threads active for follow-up work.

The merged/closed trigger is now configurable independently from the inactivity trigger. Existing users keep the current behavior unless they opt out.

This composes with #5151: open PRs remain protected from inactivity auto-settle; this setting only controls the merged/closed completion trigger.

UI Changes

Before

The inactivity setting also stated that merged and closed PR threads always settle, with no separate control.

Before: Sidebar v2 has no separate pull-request auto-settle setting

After

A separate toggle controls merged/closed-PR settlement. Here it is disabled while inactivity-based settlement remains enabled.

After: Sidebar v2 has an independent merged-or-closed PR auto-settle toggle

Validation

  • bun test packages/contracts/src/settings.test.ts packages/client-runtime/src/state/threadSettled.test.ts apps/mobile/src/features/threads/threadListV2.test.ts — 251 passed
  • bun --cwd apps/web test -- src/components/settings/settingsSearch.test.ts — 8 passed
  • bun --cwd apps/desktop test -- DesktopClientSettings.test.ts — 7 passed
  • Typechecks passed for contracts, client runtime, web, and mobile
  • Targeted lint and formatting checks passed for all 18 changed files
  • Verified in an empty, isolated local T3 home that the setting defaults on, persists off across reload, remains independent from inactivity settlement, and persists when re-enabled

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for the UI change
  • No animation or timing behavior changed, so a video is not applicable

Built with GPT-5.6-Sol via the Codex harness in T3 Code.

Note

Add auto-settle toggle for merged/closed PR threads across web and mobile

  • Adds sidebarAutoSettleOnChangeRequestCompletion to ClientSettingsSchema (default true) so users can disable auto-settling threads when a PR is merged or closed.
  • Extends effectiveSettled to gate the PR-completion branch on the new flag; existing behavior is unchanged when the flag is omitted.
  • Web: adds a toggle in BetaSettingsPanel, wires it through useClientThreadSettlementPreferences into SidebarV2 and ChatView.
  • Mobile: persists two new device-local preferences (threadListV2AutoSettleInactive, threadListV2AutoSettleOnChangeRequestCompletion), exposed via toggles in SettingsRouteScreen and consumed by HomeScreen and ThreadNavigationSidebar.
  • Behavioral Change: preferences are held off (no auto-settling) until client settings are fully hydrated, preventing premature thread classification on load.

Macroscope summarized 2689452.

Summary by CodeRabbit

  • New Features

    • Added separate controls for automatically settling inactive threads and threads linked to merged or closed pull requests.
    • Applied these preferences across web and mobile thread lists, with sensible defaults.
    • Added settings search support for the new automatic-settling option.
  • Documentation

    • Documented automatic thread-settling behavior, defaults, mobile support, and manual-only options.
  • Bug Fixes

    • Threads remain active when automatic settling for completed pull requests is disabled.

Note

Low Risk
Preference and UI changes around thread list classification; defaults preserve existing behavior and settlement logic is covered by targeted tests.

Overview
Adds sidebarAutoSettleOnChangeRequestCompletion (default on) so merged/closed PR auto-settling is no longer tied to the inactivity setting. effectiveSettled only auto-settles on terminal PR states when that flag is enabled; manual settle, open-PR inactivity blocking, and the inactivity window stay unchanged.

Web/desktop expose a separate Beta toggle and useClientThreadSettlementPreferences (hydration-safe) feeds Sidebar v2, ChatView, and settings search. Mobile mirrors the two triggers via device-local preferences, resolveThreadListV2SettlementPreferences, and switches under Thread List v2 Beta.

User docs describe controlling both automatic settle paths independently.

Reviewed by Cursor Bugbot for commit 2689452. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds a separate setting for automatic settlement after merged or closed change requests. Web and mobile settings expose both settlement triggers. Runtime and Thread List v2 classification apply the preferences and preserve manual settlement behavior.

Changes

Thread settlement contract and runtime

Layer / File(s) Summary
Settings contract and settlement classification
packages/contracts/src/settings.ts, packages/client-runtime/src/state/threadSettled.ts, packages/*/src/*test*, apps/desktop/src/settings/DesktopClientSettings.test.ts
Client settings default change-request completion settlement to enabled. effectiveSettled skips merged or closed change-request settlement when disabled. Tests cover defaults, patches, and manual-only behavior.

Web controls and consumers

Layer / File(s) Summary
Web settings and settlement consumers
apps/web/src/components/settings/BetaSettingsPanel.tsx, apps/web/src/components/settings/settingsSearch.*, apps/web/src/components/SidebarV2.tsx, apps/web/src/components/ChatView.tsx, docs/user/source-control.md
Web settings expose independent inactivity and merged/closed change-request controls. Sidebar and chat settlement evaluation receive the new preference. Documentation and settings search include the control.

Mobile Thread List v2

Layer / File(s) Summary
Mobile preference storage and resolution
apps/mobile/src/persistence/mobile-preferences.ts, apps/mobile/src/features/threads/threadListV2.ts, apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts
Mobile preferences store both flags. A shared resolver applies the three-day inactivity default and enables change-request completion settlement unless explicitly disabled.
Mobile consumers and settings
apps/mobile/src/features/home/HomeScreen.tsx, apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx, apps/mobile/src/features/settings/SettingsRouteScreen.tsx, apps/mobile/src/features/threads/threadListV2.test.ts
Home, sidebar, and Thread List v2 use resolved preferences. Mobile Beta settings persist both switches. Tests cover defaults and active-list classification.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SettingsPanel
  participant ClientSettings
  participant SidebarV2
  participant effectiveSettled
  SettingsPanel->>ClientSettings: update merged/closed auto-settle setting
  ClientSettings->>SidebarV2: provide setting
  SidebarV2->>effectiveSettled: evaluate thread state and preference
  effectiveSettled-->>SidebarV2: settled or active classification
Loading

Possibly related PRs

Suggested reviewers: t3dotgg, shivamhwp

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #4982 by separating settlement triggers, preserving defaults and manual behavior, and enabling fully manual settlement.
Out of Scope Changes check ✅ Passed The web, desktop, mobile, runtime, contract, test, and documentation changes directly support the requested auto-settle feature.
Title check ✅ Passed The title clearly and concisely describes the addition of a pull-request auto-settle toggle.
Description check ✅ Passed The description covers the required changes, rationale, UI updates, validation, screenshots, and checklist items.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 31, 2026
@caezium
caezium marked this pull request as ready for review July 31, 2026 20:38
@macroscopeapp

macroscopeapp Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

New feature adding a user-facing settings toggle across web, mobile, and desktop that changes thread auto-settlement behavior. Cross-platform feature additions warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@caezium
caezium force-pushed the feat/auto-settle-merged-pr-toggle branch from 1f2d7cb to 2585df2 Compare August 1, 2026 08:26

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2585df2. Configure here.

Comment thread apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts
@caezium

caezium commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/mobile/src/features/threads/threadListV2.ts (1)

33-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use inferred return types.

Both functions infer their return shape from the returned object.

  • apps/mobile/src/features/threads/threadListV2.ts#L33-L39: Remove the explicit return type from resolveThreadListV2SettlementPreferences.
  • apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts#L25-L28: Remove the explicit return type from useThreadListV2SettlementPreferences.

As per coding guidelines, “Prefer inferred types over explicit annotations and do not use any.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/mobile/src/features/threads/threadListV2.ts` around lines 33 - 39,
Remove the explicit return type annotation from
resolveThreadListV2SettlementPreferences in
apps/mobile/src/features/threads/threadListV2.ts (lines 33-39) and
useThreadListV2SettlementPreferences in
apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts (lines 25-28),
allowing both functions to infer their return shapes from the returned objects.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/mobile/src/features/threads/threadListV2.ts`:
- Around line 33-39: Remove the explicit return type annotation from
resolveThreadListV2SettlementPreferences in
apps/mobile/src/features/threads/threadListV2.ts (lines 33-39) and
useThreadListV2SettlementPreferences in
apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts (lines 25-28),
allowing both functions to infer their return shapes from the returned objects.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 897164d0-2c77-4240-8eef-04ade8e5f5c0

📥 Commits

Reviewing files that changed from the base of the PR and between 0ad91b6 and 2585df2.

📒 Files selected for processing (18)
  • apps/desktop/src/settings/DesktopClientSettings.test.ts
  • apps/mobile/src/features/home/HomeScreen.tsx
  • apps/mobile/src/features/settings/SettingsRouteScreen.tsx
  • apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
  • apps/mobile/src/features/threads/threadListV2.test.ts
  • apps/mobile/src/features/threads/threadListV2.ts
  • apps/mobile/src/features/threads/use-thread-list-v2-enabled.ts
  • apps/mobile/src/persistence/mobile-preferences.ts
  • apps/web/src/components/ChatView.tsx
  • apps/web/src/components/SidebarV2.tsx
  • apps/web/src/components/settings/BetaSettingsPanel.tsx
  • apps/web/src/components/settings/settingsSearch.test.ts
  • apps/web/src/components/settings/settingsSearch.ts
  • docs/user/source-control.md
  • packages/client-runtime/src/state/threadSettled.test.ts
  • packages/client-runtime/src/state/threadSettled.ts
  • packages/contracts/src/settings.test.ts
  • packages/contracts/src/settings.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Separate toggle for merged/closed-PR auto-settle (enables fully manual settling)

1 participant